home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / kabc / ldapconfigwidget.h < prev    next >
Encoding:
C/C++ Source or Header  |  2007-01-15  |  9.1 KB  |  298 lines

  1. /*
  2.     This file is part of libkabc.
  3.     Copyright (c) 2004 Szombathelyi Gy├╢rgy <gyurco@freemail.hu>
  4.  
  5.     This library is free software; you can redistribute it and/or
  6.     modify it under the terms of the GNU Library General Public
  7.     License as published by the Free Software Foundation; either
  8.     version 2 of the License, or (at your option) any later version.
  9.  
  10.     This library is distributed in the hope that it will be useful,
  11.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13.     Library General Public License for more details.
  14.  
  15.     You should have received a copy of the GNU Library General Public License
  16.     along with this library; see the file COPYING.LIB.  If not, write to
  17.     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  18.     Boston, MA 02110-1301, USA.
  19. */
  20.  
  21. #ifndef LDAPCONFIGWIDGET_H
  22. #define LDAPCONFIGWIDGET_H
  23.  
  24. #include <qwidget.h>
  25. #include <qmap.h>
  26. #include <qstring.h>
  27.  
  28. #include <kabc/ldapurl.h>
  29. #include <kabc/ldif.h>
  30. #include <kio/job.h>
  31.  
  32. class QGridLayout;
  33. class QSpinBox;
  34. class QPushButton;
  35. class QCheckBox;
  36. class QRadioButton;
  37. class KComboBox;
  38. class KLineEdit;
  39. class KProgressDialog;
  40.  
  41. namespace KABC {
  42.  
  43.   /**
  44.     @short LDAP Configuration widget
  45.  
  46.     This class can be used to query the user for LDAP connection parameters. 
  47.     It's KConfigXT compatible, using widget names starting with kcfg_
  48.   */
  49.  
  50.   class KABC_EXPORT LdapConfigWidget : public QWidget
  51.   {
  52.     Q_OBJECT
  53.     Q_PROPERTY( LCW_Flags flags READ flags WRITE setFlags )
  54.     Q_PROPERTY( QString user READ user WRITE setUser )
  55.     Q_PROPERTY( QString password READ password WRITE setPassword )
  56.     Q_PROPERTY( QString bindDN READ bindDN WRITE setBindDN )
  57.     Q_PROPERTY( QString realm READ realm WRITE setRealm )
  58.     Q_PROPERTY( QString host READ host WRITE setHost )
  59.     Q_PROPERTY( int port READ port WRITE setPort )
  60.     Q_PROPERTY( int ver READ ver WRITE setVer )
  61.     Q_PROPERTY( QString dn READ dn WRITE setDn )
  62.     Q_PROPERTY( QString filter READ filter WRITE setFilter )
  63.     Q_PROPERTY( QString mech READ mech WRITE setMech )
  64.     Q_PROPERTY( bool secNO READ isSecNO WRITE setSecNO )
  65.     Q_PROPERTY( bool secSSL READ isSecSSL WRITE setSecSSL )
  66.     Q_PROPERTY( bool secTLS READ isSecSSL WRITE setSecTLS )
  67.     Q_PROPERTY( bool authAnon READ isAuthAnon WRITE setAuthAnon )
  68.     Q_PROPERTY( bool authSimple READ isAuthSimple WRITE setAuthSimple )
  69.     Q_PROPERTY( bool authSASL READ isAuthSASL WRITE setAuthSASL )
  70.     Q_PROPERTY( int sizeLimit READ sizeLimit WRITE setSizeLimit )
  71.     Q_PROPERTY( int timeLimit READ timeLimit WRITE setTimeLimit )
  72.     Q_SETS ( LCW_Flags )
  73.         
  74.     public:
  75.     
  76.       enum LCW_Flags {
  77.         W_USER = 0x1,
  78.         W_PASS = 0x2,
  79.         W_BINDDN = 0x4,
  80.         W_REALM = 0x8,
  81.         W_HOST = 0x10,
  82.         W_PORT = 0x20,
  83.         W_VER = 0x40,
  84.         W_DN = 0x80,
  85.         W_FILTER = 0x100,
  86.         W_SECBOX = 0x400,
  87.         W_AUTHBOX = 0x800,
  88.         W_TIMELIMIT = 0x1000,
  89.         W_SIZELIMIT = 0x2000,
  90.         W_ALL = 0xFFFFFFF
  91.       };
  92.       
  93.       /** Constructs an empty configuration widget.
  94.        * You need to call setFlags() after this.
  95.        */
  96.       LdapConfigWidget( QWidget* parent = 0, 
  97.         const char* name = 0, WFlags fl = 0 );
  98.       /** Constructs a configuration widget */
  99.       LdapConfigWidget( int flags, QWidget* parent = 0,
  100.         const char* name = 0, WFlags fl = 0 );
  101.       /** Destructs a configuration widget */
  102.       virtual ~LdapConfigWidget();
  103.  
  104.       /** Sets the user name. Kconfig widget name: kcfg_ldapuser */
  105.       void setUser( const QString &user );
  106.       /** Gets the user name. Kconfig widget name: kcfg_ldapuser */
  107.       QString user() const;
  108.  
  109.       /** Sets the password. Kconfig widget name: kcfg_ldappassword */
  110.       void setPassword( const QString &password );
  111.       /** Gets the password. Kconfig widget name: kcfg_ldappassword */
  112.       QString password() const;
  113.  
  114.       /**
  115.        * Sets the bind dn. Useful for SASL proxy auth.
  116.        * Kconfig widget name: kcfg_ldapbinddn
  117.        */
  118.       void setBindDN( const QString &binddn );
  119.       /** Gets the bind dn. Kconfig widget name: kcfg_ldapbinddn*/
  120.       QString bindDN() const;
  121.  
  122.       /** Sets the SASL realm. Kconfig widget name: kcfg_ldaprealm */
  123.       void setRealm( const QString &realm );
  124.       /** Gets the SASL realm. Kconfig widget name: kcfg_ldaprealm */
  125.       QString realm() const;
  126.  
  127.       /** Sets the host name. Kconfig widget name: kcfg_ldaphost */
  128.       void setHost( const QString &host );
  129.       /** Gets the host name. Kconfig widget name: kcfg_ldaphost */
  130.       QString host() const;
  131.  
  132.       /** Sets the LDAP port. Kconfig widget name: kcfg_ldapport */
  133.       void setPort( int port );
  134.       /** Gets the LDAP port. Kconfig widget name: kcfg_ldapport */
  135.       int port() const;
  136.  
  137.       /** Sets the LDAP protocol version. Kconfig widget name: kcfg_ldapver */
  138.       void setVer( int ver );
  139.       /** Gets the LDAP protocol version. Kconfig widget name: kcfg_ldapver */
  140.       int ver() const;
  141.  
  142.       /** Sets the LDAP Base DN. Kconfig widget name: kcfg_ldapdn */
  143.       void setDn( const QString &dn );
  144.       /** Gets the LDAP Base DN. Kconfig widget name: kcfg_ldapdn */
  145.       QString dn() const;
  146.  
  147.       /** Sets the LDAP Filter. Kconfig widget name: kcfg_ldapfilter */
  148.       void setFilter( const QString &filter );
  149.       /** Gets the LDAP Filter. Kconfig widget name: kcfg_ldapfilter */
  150.       QString filter() const;
  151.  
  152.       /** Sets the SASL Mechanism. Kconfig widget name: kcfg_ldapsaslmech */
  153.       void setMech( const QString &mech );
  154.       /** Gets the SASL Mechanism. Kconfig widget name: kcfg_ldapsaslmech */
  155.       QString mech() const;
  156.  
  157.       /**
  158.        * Sets the configuration to no transport security.
  159.        * Kconfig widget name: kcfg_ldapnosec
  160.        */
  161.       void setSecNO( bool b = true );
  162.       /**
  163.        * Returns true if no transport security selected.
  164.        * Kconfig widget name: kcfg_ldapnosec
  165.        */
  166.       bool isSecNO() const;
  167.  
  168.       /**
  169.        * Sets the configuration to TLS.
  170.        * Kconfig widget name: kcfg_ldaptls
  171.        */
  172.       void setSecTLS( bool b = true );
  173.       /**
  174.        * Returns true if TLS selected.
  175.        * Kconfig widget name: kcfg_ldaptls
  176.        */
  177.       bool isSecTLS() const;
  178.  
  179.       /**
  180.        * Sets the configuration to SSL.
  181.        * Kconfig widget name: kcfg_ldapssl
  182.        */
  183.       void setSecSSL( bool b = true );
  184.       /**
  185.        * Returns true if SSL selected.
  186.        * Kconfig widget name: kcfg_ldapssl
  187.        */
  188.       bool isSecSSL() const;
  189.  
  190.       /**
  191.        * Sets the authentication to anonymous.
  192.        * Kconfig widget name: kcfg_ldapanon
  193.        */
  194.       void setAuthAnon( bool b = true );
  195.       /**
  196.        * Returns true if Anonymous authentication selected.
  197.        * Kconfig widget name: kcfg_ldapanon
  198.        */
  199.       bool isAuthAnon() const;
  200.  
  201.       /**
  202.        * Sets the authentication to simple.
  203.        * Kconfig widget name: kcfg_ldapsimple
  204.        */
  205.       void setAuthSimple( bool b = true );
  206.       /**
  207.        * Returns true if Simple authentication selected.
  208.        * Kconfig widget name: kcfg_ldapsimple
  209.        */
  210.       bool isAuthSimple() const;
  211.  
  212.       /**
  213.        * Sets the authentication to SASL.
  214.        * Kconfig widget name: kcfg_ldapsasl
  215.        */
  216.       void setAuthSASL( bool b = true );
  217.       /**
  218.        * Returns true if SASL authentication selected.
  219.        * Kconfig widget name: kcfg_ldapsasl
  220.        */
  221.       bool isAuthSASL() const;
  222.  
  223.       /**
  224.        * Sets the size limit.
  225.        * KConfig widget name: kcfg_ldapsizelimit
  226.        */
  227.       void setSizeLimit( int sizelimit );
  228.       /**
  229.        * Returns the size limit.
  230.        * KConfig widget name: kcfg_ldapsizelimit
  231.        */
  232.       int sizeLimit() const;
  233.  
  234.       /**
  235.        * Sets the time limit.
  236.        * KConfig widget name: kcfg_ldaptimelimit
  237.        */
  238.       void setTimeLimit( int timelimit );
  239.       /**
  240.        * Returns the time limit.
  241.        * KConfig widget name: kcfg_ldaptimelimit
  242.        */
  243.       int timeLimit() const;
  244.  
  245.       int flags() const;
  246.       void setFlags( int flags );
  247.  
  248.       /**
  249.        * Returns a LDAP Url constructed from the settings given.
  250.        * Extensions are filled for use in the LDAP ioslave
  251.        */
  252.       KABC::LDAPUrl url() const;
  253.  
  254.     private slots:
  255.       void setLDAPPort();
  256.       void setLDAPSPort();
  257.       void setAnonymous( int state );
  258.       void setSimple( int state );
  259.       void setSASL( int state );
  260.       void mQueryDNClicked();
  261.       void mQueryMechClicked();
  262.       void loadData( KIO::Job*, const QByteArray& );
  263.       void loadResult( KIO::Job* );  
  264.     private:
  265.  
  266.       int mFlags;
  267.       LDIF mLdif;
  268.       QStringList mQResult;
  269.       QString mAttr;
  270.  
  271.       KLineEdit *mUser;
  272.       KLineEdit *mPassword;
  273.       KLineEdit *mHost;
  274.       QSpinBox  *mPort, *mVer, *mSizeLimit, *mTimeLimit;
  275.       KLineEdit *mDn, *mBindDN, *mRealm;
  276.       KLineEdit *mFilter;
  277.       QRadioButton *mAnonymous,*mSimple,*mSASL;
  278.       QCheckBox *mSubTree;
  279.       QPushButton *mEditButton;
  280.       QPushButton *mQueryMech;
  281.       QRadioButton *mSecNO,*mSecTLS,*mSecSSL;
  282.       KComboBox *mMech;
  283.  
  284.       QString mErrorMsg;
  285.       bool mCancelled;
  286.       KProgressDialog *mProg;
  287.  
  288.       QGridLayout *mainLayout;
  289.       class LDAPConfigWidgetPrivate;
  290.       LDAPConfigWidgetPrivate *d;
  291.  
  292.       void sendQuery();
  293.       void initWidget();
  294.   };
  295. }
  296.  
  297. #endif
  298.